import java.util.Scanner;

public class Test {
   /* public void getCustomerInfo() {

        try {

            // do something that may cause an Exception

        } catch (java.io.IOException ex) {

            System.out.print("IOException!");

        } catch (java.lang.Exception ex) {

            System.out.print("Exception!");

        }

    }*/

    public String name = "abc";
    public String password = "123";


    public void Login(String name,String password) throws NameException,PasswordException{
        if(!this.name.equals(name)){
            throw new NameException();
        }
        if(!this.password.equals(password)){
            throw new PasswordException();
        }
        System.out.println("登录成功");
    }

    public static void main(String[] args) {
        Scanner i = new Scanner(System.in);
        try{
            System.out.println("请输入用户名：");
            String username = i.nextLine();
            System.out.println("请输入密码：");
            String userword = i.nextLine();
            /*Login login = new Login();*/
            Test test = new Test();
            test.Login(username,userword);

        }catch(NameException e){
            System.out.println("捕获了异常，用户名错误");
            e.printStackTrace();

        }catch(PasswordException e){
            System.out.println("捕获了异常，密码错误");
            e.printStackTrace();
        }finally{
            i.close();
        }
    }
}
